home *** CD-ROM | disk | FTP | other *** search
- /* Useful definitions, include files etc. */
-
- #include "configure.h"
-
- /* C library stuff: */
-
- #include <stdio.h> /* Must be before stdwin.h because it defines NULL */
- #include <ctype.h>
-
- #ifdef __GNUC__ /* all protos */
- # ifdef atarist
- # include <stddef.h>
- # include <stdlib.h>
- # include <string.h>
- # include <memory.h>
- # include <unixlib.h>
- # endif
- #endif
-
- #ifdef __STDC__
- #include <string.h>
- #else
- #ifdef SYSV
-
- #include <string.h>
- #define index strchr
- #define rindex strrchr
-
- #else
-
- #include <strings.h>
- #ifdef LSC
- #define index strchr
- #define rindex strrchr
- #else
- #define strchr index
- #define strrchr rindex
- #endif
-
- #endif
- #endif
-
- #ifndef _SIZE_T
- #define size_t unsigned int /* or whatever is appro */
- #define _SIZE_T
- #endif
-
- #ifdef __STDC__
- void *malloc(size_t), *calloc(size_t, size_t), *realloc(void *, size_t);
- void free(void *);
- #else
- #ifdef THINK_C
- void *malloc(), *calloc(), *realloc();
- #else
- char *malloc(), *calloc(), *realloc();
- #endif
- int free();
- #endif
-
-
- char *ctime();
- #ifndef LSC
- long time();
- #endif
-
- char *getenv();
-
- extern int errno;
-
- #ifdef NO_MEMCPY
- #define memcpy(dest, src, n) bcopy(src, dest, n)
- #define memcmp(a, b, cnt) bcmp(a, b, cnt)
- #else
- #ifdef __STDC__
- void * memcpy(void * dst, const void * src, size_t size);
- #else
- char *memcpy();
- int memcmp(const void *, const void *, size_t);
- #endif
- #endif
-
- /* For getopt: */
- extern int optind;
- extern char * optarg;
-
- /* Dynamic array macros: */
- #include "l_defs.h"
-
- /* Boolean data type: */
- #ifndef bool
- #define bool int
- #endif
- #define tbool char /* Tiny bool, used in structs or arrays */
- #define FALSE 0
- #define TRUE 1
-
- /* Character shorthands: */
- #define EOS '\0'
- #define EOL '\n'
-
- /* Copy string to malloc'ed memory: */
- char *strdup();
- char *strndup();
-
- /* Other useful macros: */
-
- #define CNTRL(x) ((x) & 0x1f) /* Usage: CNTRL('X') */
-
- #define ABS(x) ((x) < 0 ? -(x) : (x))
-
- #ifndef MIN
- #define MIN(a, b) ((a) < (b) ? (a) : (b))
- #endif
- #ifndef MAX
- #define MAX(a, b) ((a) > (b) ? (a) : (b))
- #endif
-
- #define CLIPMIN(var, min) if ((var) >= (min)) ; else (var)= (min)
- #define CLIPMAX(var, max) if ((var) <= (max)) ; else (var)= (max)
-
- /* Memory allocation macros: */
-
- #define ALLOC(type) ((type*) malloc((size_t)sizeof(type)))
-
- /* Array (re)allocation macros.
- RESIZE yields nonzero if the realloc succeeded. */
-
- #define NALLOC(type, n) ((type*) malloc((size_t)((n) * sizeof(type))))
- #ifdef __STDC__
- #define FREE(p) ((p) ? free((void*)(p)) : 0, (p)= 0)
- #define RESIZE(var, type, n) \
- (var= (type *) realloc((void*)var, (size_t)((n) * sizeof(type))))
- #else
- #define FREE(p) ((p) ? free((char*)(p)) : 0, (p)= 0)
- #define RESIZE(var, type, n) \
- (var= (type *) realloc((char*)var, (size_t)((n) * sizeof(type))))
- #endif
-
- #ifdef __STDC__
- # define P(s) s
- #else
- # define P(s) ()
- #endif
-
- /* endian.c */
- void endianism P((void ));
-
- /* glob.c */
- int glob P((char *pat , char *buf , unsigned int size ));
-
- /* monocase.c */
- int monocasecmp P((char *a , char *b ));
-
- /* strdup.c */
- char *strdup P((const char *str ));
- char *strndup P((char *str , int len ));
-
- /* swap.c */
- void shortswap P((short *data , int len ));
- void longswap P((long *data , int len ));
- void swpscpy P((short *dst , short *src , int nshorts ));
- void swplcpy P((long *dst , long *src , int nlongs ));
-
- #undef P
-